﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.Composition;
using An_Im.Extension.Contract;
using PPT = Microsoft.Office.Interop.PowerPoint;
using TOOL = Microsoft.Office.Tools;

namespace An_Im.ExtraGames
{
    [Export(typeof(IExtend))]
    public class AddInEntry : IExtend
    {
        public string Name => "测试用的拓展包";
        public string Description => "没有任何实际意义。";
        public string Author => "fanbal";
        public string Version => "0.1";

        PPT.Application App;

        TOOL.CustomTaskPaneCollection CustomTaskPaneCollection;

        public IEnumerable<IAnImCommand> CustomCommandList { get; private set; }

        public void Initialize(PPT.Application application, TOOL.CustomTaskPaneCollection customTaskPaneCollection)
        {
            App = application;
            CustomTaskPaneCollection = customTaskPaneCollection;
            var customCommandList = new List<IAnImCommand>();

            customCommandList.Add(new CommonCommand("新年主题", "让PPT变得喜庆一些", null, (a, l) =>
            {
                try
                {
                    var w = a.ActivePresentation.PageSetup.SlideWidth;
                    var h = a.ActivePresentation.PageSetup.SlideHeight;
                    foreach (PPT.Slide sld in a.ActivePresentation.Slides)
                    {
                        var shp = sld.Shapes.AddShape(Microsoft.Office.Core.MsoAutoShapeType.msoShapeRectangle, 0, 0, w, h);
                        shp.Fill.ForeColor.RGB = 255;
                    }
                }
                catch (Exception)
                {
                    System.Windows.Forms.MessageBox.Show("Error");
                }
            }));
            CustomCommandList = customCommandList;
        }




    }

}
